using NHibernate;
using SmartHRMS.Infrastructure.Query;

namespace SmartHRMS.NhibernateRepository
{
    public class QueryTranslator
    {
        public static ICriteria GetCriteriaFrom(ICriteria Criteria, Query Query)
        {
            foreach (Criteria c in Query.Criteria)
            {
                switch (c.CriteriaOperator)
                {
                    case CriteriaOperator.Equals:
						
                        Criteria.Add(NHibernate.Criterion.Expression.Eq(c.PropertyName, c.Value));
                        break;
						
                    case CriteriaOperator.Like:
                        Criteria.Add(NHibernate.Criterion.Expression.Like(c.PropertyName, string.Format("{0}%", c.Value)));
                        break;
                // I would add more criteria options
                // here as and when I need them
                }
            }
			
            return Criteria;
        }
    }
}
